using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ShivamEMR.Model.Domain.UIDomain;
using ShivamEMR.Model.DataInterfaces.UIDataInterf;
using ShivamEMR.Model;
//using ShivamEMR.Web.Areas.UI.Models;

namespace ShivamEMR.Web.Areas.UI.Controllers
{   
    public class UIStyleController : Controller
    {
		private readonly IUIStyleRepository uistyleRepository;

		// If you are using Dependency Injection, you can delete the following constructor
        public UIStyleController() 
        {
            uistyleRepository = Registry.RepositoryFactory.GetUIStyleRepository();
        }

        public UIStyleController(IUIStyleRepository uistyleRepository)
        {
			this.uistyleRepository = uistyleRepository;
        }

        //
        // GET: /UIStyle/

        public ViewResult Index()
        {
           // return View(uistyleRepository.AllIncluding(uistyle => uistyle.Menus));
            return View(uistyleRepository.All);
        }

        //
        // GET: /UIStyle/Details/5

        public ViewResult Details(int id)
        {
            return View(uistyleRepository.Find(id));
        }

        //
        // GET: /UIStyle/Create

        public ActionResult Create()
        {
            return View();
        } 

        //
        // POST: /UIStyle/Create

        [HttpPost]
        public ActionResult Create(UIStyle uistyle)
        {
            if (ModelState.IsValid) {
                uistyleRepository.Create(uistyle);
                uistyleRepository.Save();
                return RedirectToAction("Index");
            } else {
				return View();
			}
        }
        
        //
        // GET: /UIStyle/Edit/5
 
        public ActionResult Edit(int id)
        {
             return View(uistyleRepository.Find(id));
        }

        //
        // POST: /UIStyle/Edit/5

        [HttpPost]
        public ActionResult Edit(UIStyle uistyle)
        {
            if (ModelState.IsValid) {
                uistyleRepository.Update(uistyle);
                uistyleRepository.Save();
                return RedirectToAction("Index");
            } else {
				return View();
			}
        }

        //
        // GET: /UIStyle/Delete/5
 
        public ActionResult Delete(int id)
        {
            return View(uistyleRepository.Find(id));
        }

        //
        // POST: /UIStyle/Delete/5

        [HttpPost, ActionName("Delete")]
        public ActionResult DeleteConfirmed(int id)
        {
           // uistyleRepository.Delete(id);
            var uis = uistyleRepository.Find(id);
            uistyleRepository.Delete(uis);
            uistyleRepository.Save();

            return RedirectToAction("Index");
        }
    }
}

